<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<c:set var="jpath" value="${pageContext.request.contextPath }"/>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>Bootstrap表单组件 - Bootstrap后台管理系统模版Ace下载</title>
		<meta name="keywords" content="Bootstrap模版,Bootstrap模版下载,Bootstrap教程,Bootstrap中文" />
		<meta name="description" content="站长素材提供Bootstrap模版,Bootstrap教程,Bootstrap中文翻译等相关Bootstrap插件下载" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<%@include file="css.jsp"%>
	</head>

	<body>
						<div class="page-header">
							<h1>
								Form Elements
								<small>
									<i class="icon-double-angle-right"></i>
									Common form elements and layouts
								</small>
							</h1>
						</div><!-- /.page-header -->

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->

								<form class="form-horizontal" method="post" id="stuForm" action="" role="form">
									<div class="form-group">
										<label class="col-sm-4 control-label no-padding-right" for="form-field-1"> 姓名 </label>

										<div class="col-sm-8">
											<input type="text" placeholder="姓名" id="name" name="user_name" class="col-xs-10 col-sm-5" />
										</div>
									</div>

									<div class="space-4"></div>
									<div class="form-group">
										<label class="col-sm-4 control-label no-padding-right" for="form-field-1"> 电话 </label>

										<div class="col-sm-8">
											<input type="text" placeholder="电话" id="tel" name="user_tel" class="col-xs-10 col-sm-5" />
										</div>
									</div>

									<div class="space-4"></div>

											<div class="modal-footer" style="text-align: center;">
												<button class="btn btn-sm" data-dismiss="modal">
													<i class="icon-remove"></i>
													刷新
												</button>

												<button type="button" id="subBtn" class="btn btn-sm btn-primary">
													<i class="icon-ok"></i>
													提交
												</button>
											</div>
				</form>
							</div>
					</div>
<%@include file="js.jsp"%>
<script type="text/javascript">
	//${jpath}/substu
	function getForm(_from){
			var dataJson = "";
			var dataArr = [];
		$("#stuForm").find("input").each(function(index,_this){
			var inputName = $(_this).attr("name");
			if(inputName!=""&&inputName!=null){
				dataArr.push(inputName+":'" + $(_this).val()+"'");
			};
		});
		dataJson = "{"+dataArr.join(",")+"}";
		var jsonForms=eval("("+dataJson+")");
		return jsonForms;
	};
	$(function(){
		$("#subBtn").click(function(){
			var jsonForms = getForm("#stuForm");
			$.post("${jpath}/substu",jsonForms,function(data){
				console.log(data);
				var json = $.parseJSON(data);
				alert(json.resMsg);
				if(json.resMsg=="添加成功"){
					$("#stuForm").find("input").each(function(index,_this){
						 $(_this).val("");
					});
				};
			});
		});
	});
</script>
</body>
</html>
